

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as prefix0;

import 'tabspage/homepage.dart';
import 'tabspage/Category.dart';
import 'tabspage/Setting.dart';
 class Tabs extends StatefulWidget {
  final int index;
  Tabs({Key key,this.index=0}) : super(key: key);

  @override
  _TabsState createState() => _TabsState(currentIndex:index);
}

class _TabsState extends State<Tabs> {
  int currentIndex = 0;

  _TabsState({this.currentIndex}) : super();

  List myTabPage = [
    Homepage(),
    CategoryPage(),
    SettingPage()
  ];
  @override
  void initState() {
    print("11");
    currentIndex =currentIndex;
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: false,
        appBar: AppBar(
          title: Text("flutter demo"),
          centerTitle: true,
          elevation: 0,
          leading: Builder(
                  builder: (BuildContext context){
                    return IconButton(
                        icon: Icon(Icons.wifi_tethering),
                        onPressed: (){
                          Scaffold.of(context).openDrawer(); //打开抽屉
                        }
                    );
                  }
              ),

          //automaticallyImplyLeading: false,
        ),
        floatingActionButton:Container(
          height: 60,
          width: 60,
          margin: EdgeInsets.only(top: 10),
          padding: EdgeInsets.all(6),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(40)
          ),
          child: FloatingActionButton(
            child: Icon(Icons.add,color: Colors.black,size: 35,),
            onPressed: (){
              setState(() {
              this.currentIndex = 1;
              });
            },
            backgroundColor: currentIndex==1 ? Colors.red : Colors.yellow,
          ),
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        drawer: Drawer(

          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              UserAccountsDrawerHeader(
                currentAccountPicture:CircleAvatar(
                  backgroundImage:NetworkImage("https://avatar.gitee.com/uploads/49/1301149_Yi2018.png!avatar100?1492355066") ,
                ),
                accountName:Text("义少"),
                accountEmail: Text("1057202547@qq.com"),
                decoration: BoxDecoration(
                  backgroundBlendMode:BlendMode.colorBurn,
                  color: Colors.yellow,
                  image: DecorationImage(
                    fit: BoxFit.cover,
                    image:NetworkImage("https://avatar.gitee.com/uploads/49/1301149_Yi2018.png!avatar100?1492355066")
                  )
                ),
              ),
              // DrawerHeader(
              //   child: Text("你好flutterflutter",style: TextStyle(color: Colors.white),),
              //   decoration: BoxDecoration(
              //     image: DecorationImage(
              //       fit: BoxFit.cover,
              //       image:NetworkImage("https://avatar.gitee.com/uploads/49/1301149_Yi2018.png!avatar100?1492355066")
              //     )
              //   ),
              // ),
              ListTile(
                leading: CircleAvatar(
                  child: Icon(Icons.people),
                ),
                title: Text("我的空间"),
                onTap: (){
                  Navigator.of(context).pop(); //隐藏侧边栏
                  Navigator.pushNamed(context, "/search");
                },
              ),
              Divider(),
              ListTile(
                leading: CircleAvatar(
                  child: Icon(Icons.people),
                ),
                title: Text("我的空间"),
              ),
              Divider(),
              ListTile(
                leading: CircleAvatar(
                  child: Icon(Icons.people),
                ),
                title: Text("我的空间"),
              )
            ],
          ),
        ),
        endDrawer: Drawer(
          child: Text("右边抽屉"),
        ),
        body: this.myTabPage[this.currentIndex],
        bottomNavigationBar: BottomNavigationBar(
          currentIndex: currentIndex,
          iconSize: 32.0,
          fixedColor: Colors.red,
          type: BottomNavigationBarType.fixed, //底部可以有多个按钮
          onTap: (index){
            print(index);
            setState(() {
              this.currentIndex = index;
            });
          },
          items:[
            BottomNavigationBarItem(
              icon: Image.network(
                "http://p1.meituan.net/200.0/deal/74e45cd53b2f33937c3d058d325354d114273.jpg@95_0_250_250a%7C267h_267w_2e_100Q",height:25.0,width: 25.0,fit: BoxFit.cover,),
              title: Text("123")
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text("123")
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text("123")
            ),
            // BottomNavigationBarItem(
            //   icon: Icon(Icons.home),
            //   title: Text("123")
            // ),
            // BottomNavigationBarItem(
            //   icon: Icon(Icons.home),
            //   title: Text("123")
            // ),
          ]
        ),
      );
  }
}
